﻿
var cal_obj2 = null;
var datebox=null;
var format = '%m/%j/%Y';

// show calendar
function show_cal(x, y, el, txtBox) {

	if (cal_obj2) return;
dateBox=txtBox;
var text_field = document.getElementById(dateBox);

	cal_obj2 = new RichCalendar();
	cal_obj2.start_week_day = 2;
	cal_obj2.show_time = true;
	cal_obj2.language = 'en';
	cal_obj2.user_onchange_handler = cal2_on_change;
	cal_obj2.user_onclose_handler = cal2_on_close;
	cal_obj2.user_onautoclose_handler = cal2_on_autoclose;

	cal_obj2.parse_date(text_field.value, format);
	cal_obj2.show_at_elementXY(x, y, text_field, "x-y");
	cal_obj2.change_skin('alt');

}

// user defined onchange handler
function cal2_on_change(cal, object_code) {
	if (object_code == 'day') {
		document.getElementById(dateBox).value = cal.get_formatted_date(format);
		cal.hide();
		cal_obj2 = null;
	}
}

// user defined onclose handler (used in pop-up mode - when auto_close is true)
function cal2_on_close(cal) {
	if (window.confirm('Are you sure to close the calendar?')) {
		cal.hide();
		cal_obj2 = null;
	}
}

// user defined onautoclose handler
function cal2_on_autoclose(cal) {
	cal_obj2 = null;
}
